package ewms.controller;

import ewms.bo.EwmsWasteFlowInfoQueryBo;
import ewms.service.IEwmsIndexService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * 首页控制器类
 */
@Api(value = "首页控制器", tags = {"首页图表"})
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/business/index")
@Slf4j
public class EwmsIndexController {

	@Autowired
	private IEwmsIndexService indexService;

	public EwmsIndexController(IEwmsIndexService indexService) {
		this.indexService = indexService;
	}

	/**
	 * 查询各统计项总计
	 *
	 * @return
	 */
	@ApiOperation("查询各统计项总计")
	@PreAuthorize("@ss.hasPermi('business:transferWarehouse:list')")
	@GetMapping("/allItemTotal")
	public Map<String, BigDecimal> allItemTotal(@Validated EwmsWasteFlowInfoQueryBo bo) {
		return indexService.selectAllItemTotal();
	}

	/**
	 * 查询折线图数据
	 *
	 * @return
	 */
	@ApiOperation("查询折线图数据")
	@PreAuthorize("@ss.hasPermi('business:transferWarehouse:list')")
	@GetMapping("/lineChart")
	public Map<String, List> lineChart(@Validated EwmsWasteFlowInfoQueryBo bo) {
		return indexService.selectLineChart();
	}

	/**
	 * 查询焚化饼状图数据
	 *
	 * @return
	 */
	@ApiOperation("查询焚化饼状图数据")
	@PreAuthorize("@ss.hasPermi('business:transferWarehouse:list')")
	@GetMapping("/pieChart")
	public Map<String, Object> pieChart(@Validated EwmsWasteFlowInfoQueryBo bo) {
		return indexService.selectPieChart();
	}

	/**
	 * 查询焚化饼状图数据
	 *
	 * @return
	 */
	@ApiOperation("查询委外柱状图数据")
	@PreAuthorize("@ss.hasPermi('business:transferWarehouse:list')")
	@GetMapping("/barChart")
	public Map<String, Object> barChart(@Validated EwmsWasteFlowInfoQueryBo bo) {
		return indexService.selectBarChart();
	}

}
